# @Time    : 2021-04-13 10:51
# @Author  : Jackcongx
# @FileName: update_topic_time.py
# @Software: PyCharm
import datetime
import os
import sys

import django

sys.path.insert(0, "/onecity/ayc_bbs")
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ayc_bbs.settings')
django.setup()

from forum.models import Topic
from user_app.models import AccountInfo

ph = [
    "17912341111",
    "17912341112",
    "17912341113",
    "17912341114",
    "17912341115",
    "17912341116",
    "17912341117",
    "17912341118",
    "17912341119",
    "17912341121",
    "17912341122",
    "17912341123",
    "17912341124",
    "17912341125",
    "17912341126",
    "17912341127",
    "17912341128",
    "17912341129",
    "17912341131",
    "17912341132",
]


# ph = [
#     "13212789782",
#     "15727156182",
#     "18672238676"
# ]


def update_topic_time():
    account_list = AccountInfo.objects.filter(mobile_phone__in=ph)
    for topic in Topic.objects.filter(account_info__in=account_list):
        topic.created_on = datetime.datetime.now()
        topic.updated_on = datetime.datetime.now()
        topic.last_reply_on = datetime.datetime.now()
        topic.save()
        topic.refresh_from_db()


if __name__ == '__main__':
    update_topic_time()
